{extend name="template/base" /}
{block name="content"}
<div class="page-container">

    <style>

        .text-c{}
        .text-c td{border-left:none;}
        .text-c td input {width:15px;height:15px;}
        .open{position:relative;font-size:25px;}
        .open span{width:50%;height:50%;display:inline-block;border-bottom:1px #999 solid;border-left:1px #999 solid;position:absolute;right:0;top:0;}
        .open i {height:100%;width:50%;border-left:1px #999 solid;float:right;display:inline-block;position:absolute;right:0;}
        .open div{height:30%;width:50%;position:absolute;right:0;bottom:0;border-left:1px #999 solid;}
        .box{border:1px #ccc solid;width:100%;display:inline-block;}
        .delete{font-size:15px;font-weight:600;background:#eee;width:15px;height:15px;border-radius:50%;line-height:12px;cursor:pointer;position:absolute;right:-5px;top:-5px;}
        .box .title{background:#eee;padding:0 20px;line-height:30px;}
        .listBox{width:100%;margin-right:-20px;display:inline-block;}
        .listBox .list{
            font-size:14px;
            color:#020202;
            background:#f5f5f5;
            border-radius:10px;
            width:138px;
            display:inline-block;
            float:left;
            margin:20px;
            text-align:center;
            position:relative;
        }
        .listBox .list span{margin:5px 0;width:60px;display:inline-block;}
        .submits {border-top:1px #ccc solid;width:100%;background:#eee;height:40px;padding:5px 0;}
        .submits button{background:#5a98dd;font-size:15px;border-radius:5px;border:none;width:50px;height:30px;line-height:30px;color:#fff;margin:0 auto;display:block;cursor:pointer;}
        .submits button:hover{background:#0a6998;}
        .selected_box{
            background:#fbdddd!important;
        }
    </style>
    {include file="form" /}

    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            <!--{tp:menu menu="add" /}-->
            <!--<a class="btn btn-primary radius mr-5" href="{:url('/admin/order_traveler/export_to_excel',$searchCondition)}"  >excel导出</a>-->
            <a class="btn btn-primary radius mr-5" id="sou" href="{:url('/admin/order_traveler/export_to_excel',$searchCondition)}" >excel导出</a>
            <a class="btn btn-primary radius mr-5" id="xuan" style="display: none;"  href="javascript:;" onclick="xuan()">excel导出</a>
        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$count ?? '0'}</strong> 条
        </span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            {include file="th" /}
            <th colspan="2" width="70">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">
            {include file="td" /}
            <td class="f-14">
                <!--{$vo.status|show_status=$vo.id}-->
                {tp:menu menu='sedit' /}
                {if condition="$vo.show_mian"}
                <a title="订单信息" href="javascript:;" onclick="layer_open('订单信息','/admin/order/edit/id/{$vo.oid}.html')" style="text-decoration:none" class="label label-warning radius">订单信息</a>
                {elseif  condition="$vo.show_single" /}
                <a title="订单信息" href="javascript:;" onclick="layer_open('订单信息','/admin/order/edit/id/{$vo.oid}.html')" style="text-decoration:none" class="label label-warning radius">订单信息</a>
                {/if}
                <!--{tp:menu menu='sdelete' /}-->
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page ?? ''}</div>
    <script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>

    <!--<div class="box">-->
        <!--<div class="title">拼车结果</div>-->
        <!--<div class="listBox">-->
            <!--&lt;!&ndash;<div class="list">&ndash;&gt;-->
                <!--&lt;!&ndash;<div class="delete">×</div>&ndash;&gt;-->
                <!--&lt;!&ndash;<p class="driver driver_1" data-user_id="1">阿道夫的放到</p>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">阿道夫</span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">手动的</span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">手动的</span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">啊啊啊</span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">啊啊啊</span>&ndash;&gt;-->
                <!--&lt;!&ndash;<span class="traveler traveler_1 traveler_oid_1" data-traveler="1" data-traveler_oid="1">鹅鹅鹅</span>&ndash;&gt;-->
            <!--&lt;!&ndash;</div>&ndash;&gt;-->
        <!--</div>-->
        <!--<div class="submits">-->
            <!--<button id="submit">提交</button>-->
        <!--</div>-->
    <!--</div>-->
    <script>
        $(function () {
        })

        //全选
        $('#checkAlls').bind("click", function () {
            $("input[name='id[]']").prop("checked",this.checked);
            var sonChecked = $("input[name='id[]']").prop('checked');
            var allChecked = this.checked
            if (sonChecked && allChecked){
                $('#xuan').css('display','inline') // 显示选择excel导出数据
                $('#sou').css('display','none') // 隐藏部分或全部excel导出数据
            }else{
                $('#xuan').css('display','none')
                $('#sou').css('display','inline')
            }
            console.log('你点击我了')
            console.log('你是否被选中', this.checked)
            console.log('下级的选框', $("input[name='id[]']").prop('checked'))
        });

        // 单选
        $("input[name='id[]']").bind('click', function () {
            var radioData =  $("input:checked[name='id[]']");
            // 选择数据的长度
            var len = radioData.serializeArray().length;
            if (len > 0) {
                $('#xuan').css('display','inline') // 显示选择excel导出数据
                $('#sou').css('display','none') // 隐藏部分或全部excel导出数据
            } else {
                $('#xuan').css('display','none')
                $('#sou').css('display','inline')
                $('#checkAlls').prop('checked',false); // 取消选择全选按钮
            }
            // console.log('你点击了单选')
            // console.log('点击的结果为：', this.checked)
            // console.log('你选择的数据是', radioData.serializeArray())
            // console.log('你选择的数据长度是',len)
        });

        function xuan() {
            var checkData = $("input:checked[name='id[]']");
            var dataArr = checkData.serializeArray();
            dataArr.push({name: 'search',value: 'refund_order'})
            console.log('选择的数据是', checkData.length)
            console.log('选择的数据是', checkData.serializeArray())
            console.log('选择的数组是', dataArr)
            $.ajax({
                type: 'post',
                url: '/admin/order_traveler/export_to_excel',
                data: dataArr,
                success: function (res) {
                    if (res.code == 5){
                        console.log('data', res);
                        location.href = res.msg; // 下载文件
                        // 删除文件
                        unclinkFile(res.msg)
                        layer.msg('导出数据成功');
                    } else {
                        layer_open('excel导出数据','/admin/pub/role/id/1')
                    }
                }
            });
        }
        var  value = 1;
        setTimeout(unclinkFile,1200000,value); // 延迟20分钟1200000
        // 15分钟后删除文件-900000
        function unclinkFile(val) {
            console.log(val)
            setTimeout(function () {
                // 删除文件
                $.ajax({
                    type: 'post',
                    url: '/admin/order/del',
                    data: {val:val},
                    success: function (data) {
                        console.log('data', data)
                        if (data.code != 5) {
                            console.log('删除失败', data.msg)
                        }
                    }
                })
            },120000,val);
        }
    </script>
</div>
{/block}

